package com.levi.SimpleFactoryMode;

import com.levi.SimpleFactoryMode.Operation.*;

/**
 * @author Levi
 * @description :  Operation的简单工厂模式
 * @since 2022/8/31 10:59
 */

public class OperationFactory {
    public Operation createOperation(String operator) {
        Operation operation = null;
        switch (operator) {
            case "+":
                operation = new OperationAdd();
                break;
            case "-":
                operation = new OperationSub();
                break;
            case "*":
                operation = new OperationMul();
                break;
            case "/":
                operation = new OperationDiv();
                break;
        }
        return operation;
    }
}
